package nj.yb.entity.message;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.Date;

/**
 * 聊天消息实体
 */
public class ChatMessage {
    //消息类型
    public static final String TYPE_PRIVATE="private";
    public static final String TYPE_GROUP="group";
    //数据库主键
    private Long id;
    @JSONField(ordinal = 1)
    private String msgType;
    @JSONField(ordinal = 2)
    private String sender;
    @JSONField(ordinal = 3)
    private String receiver;
    @JSONField(ordinal = 4)
    private String content;
    @JSONField(ordinal = 5, format = "yyyy-MM-dd HH:mm:ss")
    private Date sendTime;
    @JSONField(ordinal = 6)
    private boolean isRead;
    @JSONField(ordinal = 7)
    private Long groupId;

    public ChatMessage( String msgType, String sender, String receiver, String content, Date sendTime,boolean isRead) {

        this.msgType = msgType;
        this.sender = sender;
        this.receiver = receiver;
        this.content = content;
        this.sendTime = sendTime;
        this.isRead = isRead;
    }

    public ChatMessage() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getSendTime() {
        return sendTime;
    }

    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }

    public boolean isRead() {
        return isRead;
    }

    public void setRead(boolean read) {
        isRead = read;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    @Override
    public String toString() {
        return "ChatMessage{" +
                "id=" + id +
                ", msgType='" + msgType + '\'' +
                ", sender='" + sender + '\'' +
                ", receiver='" + receiver + '\'' +
                ", content='" + content + '\'' +
                ", sendTime=" + sendTime +
                ", isRead=" + isRead +
                ", groupId=" + groupId +
                '}';
    }
}
